package com.banmao.algorithm.No201To300.No283;

public class Solution1 {

    public static void moveZeroes(int[] nums) {
        // 先通过快慢指针将非零元素前移，然后遍历剩下的元素全部赋值0
        int slow = 0, fast = 0;
        for(; fast <= nums.length - 1; fast++) {
            if(nums[fast] != 0) {
                nums[slow] = nums[fast];
                slow++;
            }
        }

        for (; slow <= nums.length - 1; slow++) {
            nums[slow] = 0;
        }

    }

}
